#include<iostream>
#include<vector>
using namespace std;

void printVector(vector<int>& v){
	for(vector<int>::iterator iter=v.begin(); iter!=v.end(); iter++){
		cout<<*iter<<" ";
	}
	cout<<endl;
}


/**
 *容量，扩容机制,capacity
 */


int main(){
	vector<int> v1={8,8,8,8};
	printVector(v1);

	cout<<"v1 size():"<<v1.size()<<endl;
	cout<<"v1 capacity():"<<v1.capacity()<<endl;
	
	v1.push_back(3);
	cout<<"this is after insert!"<<endl;
	cout<<"v1 size():"<<v1.size()<<endl;
	cout<<"v1 capacity():"<<v1.capacity()<<endl;

        v1.push_back(6);
        cout<<"this is after insert!"<<endl;
        cout<<"v1 size():"<<v1.size()<<endl;
        cout<<"v1 capacity():"<<v1.capacity()<<endl;

	v1.push_back(9);
        cout<<"this is after insert!"<<endl;
        cout<<"v1 size():"<<v1.size()<<endl;
        cout<<"v1 capacity():"<<v1.capacity()<<endl;

        v1.push_back(3);
        cout<<"this is after insert!"<<endl;
        cout<<"v1 size():"<<v1.size()<<endl;
        cout<<"v1 capacity():"<<v1.capacity()<<endl;
	
	v1.push_back(8);
        cout<<"this is after insert!"<<endl;
        cout<<"v1 size():"<<v1.size()<<endl;
        cout<<"v1 capacity():"<<v1.capacity()<<endl;

	
	for(int i=0;i<3;i++){
		v1.push_back(i);
	}	
	cout<<"this is for insert!"<<endl;
	cout<<"v1.size():"<<v1.size()<<endl;
	cout<<"v1.capacity():"<<v1.capacity()<<endl;
	
	v1.resize(18);
	cout<<"v1.size():"<<v1.size()<<endl;
        cout<<"v1.capacity():"<<v1.capacity()<<endl;
	printVector(v1);
	
	v1.resize(20,6);
	cout<<"v1.size():"<<v1.size()<<endl;
        cout<<"v1.capacity():"<<v1.capacity()<<endl;
        printVector(v1);

	v1.resize(100);
        cout<<"v1.size():"<<v1.size()<<endl;
        cout<<"v1.capacity():"<<v1.capacity()<<endl;
        printVector(v1);

	v1.resize(5);
        cout<<"v1.size():"<<v1.size()<<endl;
        cout<<"v1.capacity():"<<v1.capacity()<<endl;
        printVector(v1);

	return 0;
}
